package com.springboot.mybatis.service.threaddemo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author sunyt31481
 * @date 2020/8/6 11:13
 * @description 创建线程池的方法
 */
public class ThreadPool {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i=0;i<1000;i++){
            executorService.submit(new Task1(){
            });
        }
    }
}
class Task1 implements Runnable{
    @Override
    public void run() {
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName());
    }
}
